module.exports = (app) => {
  const apiV1Router = app.router.namespace('/api')
  const jwt = app.middleware.jwt(app.config.jwt)
  // const apiV1Router = app.router
  const { controller } = app

  const { user, goods, dict, order, file } = controller
  // 用户
  apiV1Router.post('/user/register', user.register)
  apiV1Router.post('/user/login', user.login)
  apiV1Router.get('/user/getInfo', user.getInfo)
  apiV1Router.post('/user/logout', jwt, user.logout)
  apiV1Router.post('/user/addBalance', jwt, user.addBalance)
  apiV1Router.post('/user/getIncome', jwt, user.getIncome)
  // 商品
  apiV1Router.post('/goods/add', jwt, goods.add)
  apiV1Router.get('/goods/list', goods.list)
  apiV1Router.post('/goods/addCart', jwt, goods.addCart)
  apiV1Router.get('/goods/getCart', jwt, goods.getCart)
  apiV1Router.post('/goods/clearCart', jwt, goods.clearCart)
  apiV1Router.get('/goods/getStoreList', jwt, goods.getStoreList)
  apiV1Router.post('/goods/remove', jwt, goods.remove)
  // 字典
  apiV1Router.get('/dict/list', dict.list)
  apiV1Router.post('/dict/addItem', jwt, dict.addItem)
  // 订单
  apiV1Router.post('/order/add', jwt, order.add)
  // 文件上传
  apiV1Router.post('/file/upload', jwt, file.upload)
}
